﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity.Framework;

using System.Data.Objects;

namespace Business.Operations
{
    public class MacGrupOperation
    {
        private static HPDMASEntities db = new HPDMASEntities();

        public MacGrupOperation()
        {

        }

        public static List<MacGrup> MacGrupGetAll()
        {
            var macGrupListesi = db.MacGrup.ToList();
            return macGrupListesi;
        }

        public static MacGrup MacGrupGetByMacGrupId(int macGrupId)
        {
            var macGrup = (from c in db.MacGrup where c.MacGrupID == macGrupId select c).First();
            return macGrup;
        }

        public static void MacGrupDelete(int macGrupId)
        {
            MacGrup k = (from c in db.MacGrup where c.MacGrupID == macGrupId select c).First();
            db.DeleteObject(k);
            db.SaveChanges();
        }

        public static void MacGrupInsert(MacGrup macGrup)
        {
            db.MacGrup.AddObject(macGrup);
            db.SaveChanges();
        }

        public static List<string> MacGrupAdiGetAll()
        {
            var macGrupAdi = (from c in db.MacGrup select c.MacGrupAdi).ToList();
            return macGrupAdi;
        }

        public static int MacGrupIdGetByMacGrupAdi(string grupAdi)
        {
            var macGrupId = (from c in db.MacGrup where c.MacGrupAdi == grupAdi select c.MacGrupID).First();
            return macGrupId;
        }
    }
}
